package net.jxtz.jxtzos.impl.spider;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import net.jxtz.jxtzos.entity.spider.SpiderNanchangHousingAuthority;
import net.jxtz.jxtzos.entity.web.SpiderUpgrade;
import net.jxtz.jxtzos.mapper.spider.NanchangHousingAuthorityMapper;
import net.jxtz.jxtzos.service.spider.SpiderNanchangHousingAuthorityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class HousingAuthorityServiceImpl extends ServiceImpl<NanchangHousingAuthorityMapper, SpiderNanchangHousingAuthority> implements SpiderNanchangHousingAuthorityService {


    @Autowired
    private NanchangHousingAuthorityMapper mapper;

    @Override
    public List<SpiderUpgrade> getUpgradeTimeAndCount() {
        return mapper.getUpgradeTimeAndCount();
    }

    @Override
    public List<SpiderNanchangHousingAuthority> pageList(Integer pageNum) {

        List<SpiderNanchangHousingAuthority> list = new ArrayList<>();
        while (true) {
            Page<SpiderNanchangHousingAuthority> housingAuthorityIPage = new Page<>(pageNum++, 666);
            List<SpiderNanchangHousingAuthority> records = page(housingAuthorityIPage).getRecords();
            if (records.size() == 0) {
                break;
            }
            log.info(records.size() + "");
            list.addAll(records);
        }

        return list;
    }
}
